package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.oes.dto.StudentExamDTO;
import com.rabbiter.oes.entity.ExamManage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 考试管理
 */
@Mapper
public interface ExamManageMapper extends BaseMapper<ExamManage> {

    /**
     * 某学院试卷个数
     *
     * @param collegeId
     * @return
     */
    default Long selectCountByCollegeId(Integer collegeId) {
        return selectCount(Wrappers.lambdaQuery(ExamManage.class).eq(ExamManage::getCollegeId, collegeId));
    }

    /**
     * 某科目试卷个数
     *
     * @param subjectId
     * @return
     */
    default Long selectCountBysubjectId(String subjectId) {
        return selectCount(Wrappers.lambdaQuery(ExamManage.class).eq(ExamManage::getSubjectId, subjectId));
    }

    List<ExamManage> findAll();

    Page<ExamManage> findPage(Page<ExamManage> page);

    IPage<ExamManage> findPageBytj(@Param("page") Page<ExamManage> page, @Param("description") String description, @Param("collegeId") Integer collegeId, @Param("majorId") Integer majorId);

    Page<ExamManage> studentFindPage(@Param("page") Page<ExamManage> page, @Param("dto") StudentExamDTO dto, @Param("majorId") Integer majorId, @Param("collegeId") Integer collegeId);


    ExamManage findById(Integer examCode);

    List<ExamManage> findOnlyPaperId();
}
